package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

    /**
     * 用户端营业状态查询
     *
     * @Author itcast
     * @Create 2023/4/27
     **/
    @RestController
    @RequestMapping("/user/shop")
    @Api(tags = "店铺相关接口")
    @Slf4j
    public class UserShopController {

        public static final String SHOP_STATUS_KEY = "SHOP_STATUS";

        @Autowired
        private RedisTemplate redisTemplate;

        /**
         * 用户端查询营业状态
         *
         * @return
         */
        @GetMapping("/status")
        @ApiOperation("查询营业状态")
        public Result getStatus() {
            Integer status = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS_KEY);
            return Result.success(status);
        }
    }

